Update O Set O.PaymentStatusId = 30
from [order] O
INNER JOIN Customer C ON O.CustomerId = C.Id
where o.orderkindId = 10 and 
o.boundorderId IS NULL and 
o.createdOnUtc > '2015-09-10T07:00:00' and o.CreatedOnUtc<'2015-09-11T07:00:00' AND
NOT EXISTS(SELECT Customer_Id from Customer_CustomerRole_Mapping where customer_Id = o.CustomerId and CustomerRole_Id = 9)

Update O Set O.PaymentStatusId = 30
from [order] O
INNER JOIN Customer C ON O.CustomerId = C.Id
where o.orderkindId = 10 and 
o.boundorderId IS NULL and 
o.createdOnUtc > '2015-09-11T07:00:00' and o.CreatedOnUtc<'2015-09-12T07:00:00' AND
NOT EXISTS(SELECT Customer_Id from Customer_CustomerRole_Mapping where customer_Id = o.CustomerId and CustomerRole_Id = 9)

Update O Set O.PaymentStatusId = 10
from [order] O
INNER JOIN Customer C ON O.CustomerId = C.Id
where o.orderkindId = 10 and 
o.boundorderId IS NULL and 
o.createdOnUtc > '2015-09-11T07:00:00' and o.CreatedOnUtc<'2015-09-12T07:00:00' AND
EXISTS(SELECT Customer_Id from Customer_CustomerRole_Mapping where customer_Id = o.CustomerId and CustomerRole_Id = 9)

